package com.example.allshengmedical.experimentanalyze.activity;

import java.util.ArrayList;
import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;

import com.example.allshengmedical.R;
import com.example.allshengmedical.base.BaseFragment;


//参数设置flag界面
public class FlagFragment extends BaseFragment {
	private ListView flag_listview;
	private MyFlagAdapter adapter;
	private List<String> data_list;
	private ArrayAdapter<String> arrayAdapter;

	@Override
	public int getlayout() {
		// TODO Auto-generated method stub
		return R.layout.fragment_flag;
	}

	@Override
	protected void initView() {
		// TODO Auto-generated method stub
		adapter = new MyFlagAdapter();
		flag_listview.setAdapter(adapter);
	}

	@Override
	protected void dataView() {
		// TODO Auto-generated method stub
		data_list = new ArrayList<String>();
		data_list.add("=");
		data_list.add("<");
		data_list.add(">");
		data_list.add("<=");
		data_list.add(">=");
		arrayAdapter = new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_spinner_item, data_list);
		arrayAdapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

	}

	class MyFlagAdapter extends BaseAdapter {

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return 15;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			MyHolder holder = null;
			if (convertView == null) {
				holder = new MyHolder();
				convertView = LayoutInflater.from(getActivity()).inflate(
						R.layout.item_flag_fragment, null);
				holder.con_spinner = (Spinner) convertView
						.findViewById(R.id.con_spinner);
				convertView.setTag(holder);
			} else {
				holder = (MyHolder) convertView.getTag();
			}
			holder.con_spinner.setAdapter(arrayAdapter);
			return convertView;
		}

	}

	class MyHolder {
		TextView flag_tv, attr_tv, descript_tv;
		CheckBox use_check, well_check;
		EditText value_ed;
		Spinner con_spinner;
	}
}
